//
//  ViewController.swift
//  MCComponentPublicUI
//
//  Created by 562863544@qq.com on 01/11/2019.
//  Copyright (c) 2019 562863544@qq.com. All rights reserved.
//

import UIKit
import SnapKit

import MCComponentPublicUI

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        title = "示例"
        
        view.addSubview(tableView)
        tableView.snp.remakeConstraints { (make) ->Void in
            make.left.right.top.bottom.equalTo(view)
        }
        
        
        dataArrayM = [
            "TextView - 添加点击事件",

            "CollectionView - item居左",
            "CollectionView - 瀑布流",
            
            "Button - icon&text 的位置"
        ]
    }
    
    
    
    lazy var tableView = MCTableView.mc_make(registerCell: UITableViewCell.self, delegate: self)
    
    lazy var dataArrayM: [String] = []
}

extension ViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataArrayM.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell: UITableViewCell = tableView.mc_makeCell(indexPath: indexPath)
        
        cell.textLabel?.text = dataArrayM[indexPath.row]
        
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let titleStr = dataArrayM[indexPath.row]
        
        switch titleStr {
        case "TextView - 添加点击事件":
            let vc = MCTextViewController()
            navigationController?.pushViewController(vc, animated: true)
        case "CollectionView - item居左":
            let vc = MCLeftLayoutViewController()
            navigationController?.pushViewController(vc, animated: true)
        case "CollectionView - 瀑布流":
            let vc = MCWaterfallLayoutViewController()
            navigationController?.pushViewController(vc, animated: true)
        case "Button - icon&text 的位置":
            let vc = MCButtonViewController()
            navigationController?.pushViewController(vc, animated: true)
            

        
        
        default:
            break
        }
        

    }
}
